// 定义一个通用的从对象值获取键的函数
export function getKeyByValue<T extends Record<string, any>>(
  obj: T,
  value: any,
): keyof T | undefined {
  for (const [key, val] of Object.entries(obj)) {
    if (val === value) {
      return key as keyof T
    }
  }
  return undefined
}
